<template>
  <div class="content">
    <div class="tableBox posting_box_list">
      <el-table
        :data="tableData"
        stripe
        style="width: 100%"
        v-loading="loading"
        border
      >
        <template v-for="(item,index) in allData">
          <el-table-column
            :key="index"
            v-if="item.value=='name'"
            :label="item.label"
            align="center"
          >
            <template slot-scope="scope">
              <span
                @click="handleClickNickName(scope.row)"
                style="color: #6b97eb;cursor: pointer;"
              >{{scope.row.name}}</span>
            </template>
          </el-table-column>
          <el-table-column
            :key="index"
            :prop="item.value"
            v-if="item.value!=='opt' && item.value!=='name' && item.value!='companyname'"
            :label="item.label"
            align="center"
          ></el-table-column>
          <el-table-column
            :key="index"
            v-if="item.value=='companyname'"
            :label="item.label"
            align="center"
          >
            <template slot-scope="scope">
              <span
                @click="handleClickCompanyName(scope.row)"
                style="color: #6b97eb;cursor: pointer;"
              >{{scope.row.companyname}}</span>
            </template>
          </el-table-column>
          <el-table-column
            :key="item.value"
            v-else-if="item.value=='opt'"
            label="操作"
            min-width="100px"
            align="center"
          >
            <template slot-scope="scope">
              <el-button
                @click="lookLog(scope.row)"
                type="text"
                size="small"
              >查看日志</el-button>
              <el-button
                @click="handleAabnormal(scope.row)"
                type="text"
                size="small"
                v-show="global.powerAllBtn.yccl.syclBtn"
              >处理</el-button>
              <!-- <el-button v-show="scope.row.remark === '1'" type="text" size="small" @click="remove(scope.row)">下架</el-button> -->
              <el-button
                type="text"
                size="small"
                @click="handleReport(scope.row)"
                v-show="global.powerAllBtn.yccl.sysbBtn"
              >上报</el-button>
            </template>
          </el-table-column>
        </template>
      </el-table>
    </div>
    <div style="padding:20px 0">
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="ScheduleCurrentChange"
        :current-page="pages.pagenum"
        :page-sizes="[10,20, 30, 50,100]"
        :page-size="pages.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="pages.total"
        background
      ></el-pagination>
    </div>
    <el-dialog
      :visible.sync="dialogVisible"
      width="680px"
      @close="closeDialog"
    >
      <div class="abnormal-dialog-header">
        <span>处理</span>
      </div>
      <div class="abnormal-detail-box">
        <div class="abnormal-detail-title">异常信息</div>
        <el-row class="abnormal-detail-row">
          <el-col :span="12">
            <span class="col-name">会员名称:</span>
            <span class="col-value">{{abnormaldetail.name}}</span>
          </el-col>
          <el-col :span="12">
            <span class="col-name">电话号码:</span>
            <span class="col-value">{{abnormaldetail.telnum}}</span>
          </el-col>
        </el-row>
        <el-row class="abnormal-detail-row">
          <el-col :span="12">
            <span class="col-name">面试企业:</span>
            <span class="col-value">{{abnormaldetail.companyname}}</span>
          </el-col>
          <el-col :span="12">
            <span class="col-name">面试岗位:</span>
            <span class="col-value">{{abnormaldetail.positionname}}</span>
          </el-col>
        </el-row>
        <el-row class="abnormal-detail-row">
          <el-col :span="12">
            <span class="col-name">面试时间:</span>
            <span class="col-value">{{abnormaldetail.interviewdate}}</span>
          </el-col>
          <el-col :span="12">
            <span class="col-name">操作HR:</span>
            <span class="col-value">{{abnormaldetail.hrusername}}</span>
          </el-col>
        </el-row>
        <el-row class="abnormal-detail-row">
          <el-col :span="12">
            <span class="col-name">操作时间:</span>
            <span class="col-value">{{abnormaldetail.operationdate}}</span>
          </el-col>
          <el-col :span="12">
            <span class="col-name">扣除积分:</span>
            <span class="col-value">{{abnormaldetail.interalnum}}</span>
          </el-col>
        </el-row>
      </div>
      <div class="abnormal-handle-box">
        <div class="abnormal-handle-title">异常处理</div>
        <el-row class="abnormal-handle-row">
          <el-col :span="12">
            <el-radio-group
              v-model="result"
              style="padding:0 20px"
            >
              <el-radio :label="'1'">爽约</el-radio>
              <el-radio :label="'2'">未爽约</el-radio>
              <el-radio :label="'3'">忽略</el-radio>
            </el-radio-group>
            <!-- <el-radio v-model="params.checked">未爽约</el-radio>
            <el-radio v-model="params.checked2">忽略</el-radio>-->
          </el-col>
        </el-row>
        <el-row class="abnormal-handle-row">
          <el-col :span="16">
            <el-input
              v-model="params.note"
              placeholder="备注："
            ></el-input>
          </el-col>
        </el-row>
        <div class="abnormal-dialog-btn">
          <el-button
            class="cancel-btn"
            @click="dialogVisible = false"
          >取消</el-button>
          <el-button
            class="sure-btn"
            type="primary"
            :disabled="!result"
            @click="submit"
          >确定</el-button>
        </div>
      </div>
    </el-dialog>
    <el-dialog
      :visible.sync="warnDialogVisible"
      width="500px"
      @close="closeWarnDialog"
    >
      <div class="warn-dialog-header">
        <span>上报原因</span>
      </div>
      <div class="warn-dialog-body">
        <div class="warn-dialog-body-title">发送内容</div>
        <el-input
          type="textarea"
          :rows="6"
          v-model.trim="reportContent"
        ></el-input>
        <div class="warn-dialog-btn">
          <el-button
            style="margin-right: 30px;"
            @click="warnDialogVisible = false"
          >取消</el-button>
          <el-button
            type="primary"
            @click="confirmReport"
          >确定</el-button>
        </div>
      </div>
    </el-dialog>
    <el-dialog
      :visible.sync="showLog"
      width="1024px"
      custom-class="showlog"
    >
      <showLog :reportid="reportId"></showLog>
    </el-dialog>
    <el-dialog
      :visible.sync="dialoghyVisible"
      width="1040px"
    >
      <resume-detail
        v-if="dialoghyVisible"
        :userid="userid"
        :nickName="nickName"
        :isShowTelphone="true"
      ></resume-detail>
    </el-dialog>
    <el-dialog
      :visible.sync="dialogVisible2"
      width="1040px"
    >
      <company-detail
        v-if="dialogVisible2"
        :companyName="companyname"
        :companyId="companyid"
        :type="'0'"
        :tabNum="'4'"
      ></company-detail>
    </el-dialog>
  </div>
</template>
<script>
import showLog from "../showLog.vue";
import resumeDetail from "../../../component/resumeDetail/index.vue";
// import companyDetail from '../../../component/companyDetail/index.vue';
import companyDetail from "../../socical/socialCheck/check.vue";

export default {
  data () {
    return {
      tableData: [],
      loading: false,
      allData: [],
      pages: {
        pagesize: 10,
        total: 0,
        pagenum: 1,
      },
      dialogVisible: false,
      abnormaldetail: {},
      warnDialogVisible: false,//上报弹窗
      reportContent: '',//上报原因
      companyType: '',//上报type
      reportId: '',//上报id
      reportStatus: "",
      params: {
        reviewid: "",
        type: "",
        note: "",
      },
      result: '',
      showLog: false,
      dialoghyVisible: false,
      userid: '',
      nickName: '',
      dialogVisible2: false,
      companyid: '',
      companyname: ''
    }
  },
  components: {
    showLog,
    resumeDetail,
    companyDetail
  },
  props: ['type'],
  created () {
    this.allData = [{
      label: "会员名称",
      value: "name"
    }, {
      label: "手机号码",
      value: "telnum"
    },
    {
      label: "应聘企业名称",
      value: "companyname"
    },
    {
      label: "面试岗位",
      value: "positionname"
    },
    {
      label: "面试时间",
      value: "interviewdate"
    },
    {
      label: "操作时间",
      value: "operationdate"
    },
    {
      label: "操作",
      value: "opt"
    }
    ]
    this.global = this.GLOBAL;
    this.getData();
  },
  methods: {
    //获取列表
    getData () {
      if (!this.type) {
        return;
      }
      this.loading = true;

      this.$axios.post('/app/v1/platform/unusual/todoList', {
        "type": this.type,
        pagesize: this.pages.pagesize,
        pagenum: this.pages.pagenum
      }).then(resp => {
        if (resp.data.message === 'success.') {
          this.tableData = resp.data.data.list;
          this.pages.total = Number(resp.data.data.totalnum);
          this.pages.pagesize = Number(resp.data.data.pagesize);
          this.loading = false;

        }
      })
    },
    // 查看会员详情
    handleClickNickName (row) {
      this.userid = row.userid;
      this.nickName = row.name;
      this.dialoghyVisible = true;
    },
    // 查看公司详情
    handleClickCompanyName (row) {
      this.companyid = row.companyid;
      this.companyname = row.companyname;
      this.dialogVisible2 = true;
    },
    // 处理异常
    handleAabnormal (row) {
      this.reportId = row.reportid;
      this.abnormaldetail = row;
      this.params.reviewid = row.reviewid;
      this.dialogVisible = true;
    },
    submit () {
      this.$confirm('此操作将处理该异常, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        if (this.result == "3") {
          let currentData = {
            reportid: this.reportId,
            status: 2,
            content: this.params.note || '暂不处理'
          }
          this.reportCall(currentData)
        } else {
           this.params.type = this.result;
          this.$axios.post("/app/v1/platform/abnormal/breakInterviewCommit", this.params).then(res => {
            if (res.data.message === 'success.') {
              this.$message({
                message: "处理成功!",
                type: "success"
              });
            } else {
              this.$message({
                message: res.data.message,
                type: "error"
              });
            }
            this.dialogVisible = false;
            this.getData();
          })
        }

      }).catch(() => {
        console.log('已取消操作');
      });
    },
    closeDialog () {
      this.abnormaldetail = {};
      this.params.reviewid = "";
      this.params.checked = false;
      this.result = '';
      this.params.note = "";
    },
    close () {
      this.checkFlag = false;
      this.getData(this.companyType);
    },

    handleReport (row) {
      this.reportId = row.reportid;
      this.reportContent = '';
      this.warnDialogVisible = true;
    },
    //上报里确定
    confirmReport () {
      if (!this.reportContent) {
        this.$message({
          type: "warning",
          message: "上报内容不能为空!"
        });
        return;
      }
      let currentData = {
        reportid: this.reportId,
        status: 0,
        content: this.reportContent || ''
      }
      this.reportCall(currentData)
    },
    //待办提交
    reportCall (data) {
      this.$axios.post('app/v1/platform/unusual/todoHandleSubmit',
        data
      ).then(resp => {
        if (resp.data.message === 'success.') {
          this.warnDialogVisible = false;
          this.dialogVisible = false;
          // this.tableData = resp.data.data;
          // this.pages.total = resp.data.data.length;
          this.loading = false;
          this.getData();
        } else {
          this.warnDialogVisible = false;
          this.dialogVisible = false;
          this.$message({
            message: resp.data.message,
            type: "error"
          });
        }
      })

    },
    handleSizeChange (val) {
      this.pages.pagenum = 1;
      this.pages.pagesize = val;
      this.getData();
    },
    //分页查询
    ScheduleCurrentChange (val) {
      this.pages.pagenum = val;
      this.getData();
    },
    reportCallback (currentData) {
      var data = {
        reportid: this.reportId,
        status: currentData.status,
        content: currentData.content || ''
      }
      this.$emit('reportCallback', data)
    },
    closeWarnDialog () {
      this.reportContent = "";
    },
    lookLog (row) {
      this.reportId = row.reportid;
      this.showLog = true;
    }
  },


}
</script>
<style>
/* 上报原因样式 */
.warn-dialog-header {
  font-size: 16px;
  box-sizing: border-box;
  padding: 20px;
  border-bottom: 1px solid #bfbfbf;
}

.warn-dialog-header::before {
  content: "";
  border-left: 8px solid #0064e4;
  margin-right: 10px;
}

.warn-dialog-body {
  box-sizing: border-box;
  padding: 20px;
}

.warn-dialog-body-title {
  font-size: 16px;
  margin-bottom: 20px;
}

.warn-dialog-btn {
  margin-top: 20px;
  text-align: center;
}
</style>



